const { globSync } = require("glob");
const { readFileSync, writeFileSync } = require("node:fs");

const splitLength = 100
const temp = []
const source = JSON.parse(readFileSync('locales/zh.json', 'utf8'))
Object.keys(source).forEach((key, index) => {

  if (!temp.length) {
    temp.push([])
  }
  const last = temp[temp.length - 1]
  if (last.length < splitLength) {
    last.push(key)
  } else {
    temp.push([])
    const last = temp[temp.length - 1]
    last.push(key)
  }
})

temp.forEach((el, index) => {
  const fileObj = el.reduce((pre, cur) => {
    pre[cur] = source[cur]
    return pre
  }, {})
  writeFileSync(`script/zh/zh-${index}.json`, JSON.stringify(fileObj, null, 2))
})